#include <iostream>
using namespace std;
constexpr int MAXN = 100;
int par[MAXN], ranks[MAXN];

void init(int n) {
    for (int i = 0; i < n; i++) {
        ranks[i] = 0;
        par[i] = i;
    }
}

int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]); // 进行路径压缩
}

void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (ranks[x] < ranks[y])
        par[x] = y;
    else {
        par[y] = x;
        if (ranks[x] == ranks[y]) ranks[x]++;
    }
}


bool same(int x, int y) {
    return find(x) == find(y);
    
}